# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class SquareMusicSearchIn(BaseModel):
    """ 音乐广场搜索参数 """
    page_no: int = Query(gt=0, default=1, description="当前页码")
    page_size: int = Query(gt=0, le=200, default=15, description="每页条数")
    name: Union[str, None] = Query(default=None, description="音乐名称")
    user: Union[str, None] = Query(default=None, description="用户编号")
    cate_id: Union[int, str, None] = Query(default="", description="所属分类")
    is_enable: Union[int, str, None] = Query(default="", description="是否显示: [0=否, 1=是]")
    audit_status: Union[int, str, None] = Query(default="", description="审核状态: [0=待审, 1=通过, 2=拒绝]")
    start_time: Union[int, str, None] = Query(default=None, description="开始时间")
    end_time: Union[int, str, None] = Query(default=None, description="结束时间")


class SquareMusicAuditIn(BaseModel):
    """ 音乐广场审核参数 """
    id: int = Field(..., gt=0, description="广场ID")
    audit_result: str = Field(default="", max_length=300, description="拒绝原因")
    audit_status: int = Field(ge=1, le=2, description="是否显示: [1=通过, 2=拒绝]")


class SquareMusicEditIn(BaseModel):
    """ 音乐广场编辑参数 """
    id: int = Field(..., gt=0, description="广场ID")
    cate_id: int = Field(..., ge=0, description="分类ID")
    sort: int = Field(default=0, ge=0, le=999999, description="排序编号")
    is_enable: int = Field(ge=0, le=1, description="是否显示: [0=否, 1=是]")


class SquareMusicIdIn(BaseModel):
    """ 音乐广场ID参数 """
    id: int = Field(..., gt=0, description="广场ID")
    reason: str = Field(default="", description="原因描述")


"""--------------- Separator ---------------"""


class SquareMusicListVo(BaseModel):
    """ 音乐广场列表Vo """
    id: int = Field(description="ID")
    cate_id: int = Field(description="分类ID")
    category: str = Field(description="所属分类")
    music_code: str = Field(description="音乐编号")
    cover_url: str = Field(description="音乐封面")
    audio_url: str = Field(description="音乐地址")
    title: str = Field(description="音乐标题")
    tags: str = Field(description="音乐风格")
    prompt: str = Field(description="音乐描述")
    lyric: str = Field(description="音乐歌词")
    duration: int = Field(description="音乐时长")
    sort: int = Field(description="分类排序")
    source: int = Field(description="来源: [1=后台, 2=用户]")
    public_sum: int = Field(description="公开次数")
    audit_result: str = Field(description="审核结果")
    audit_status: int = Field(description="审核状态: [0=待审, 1=通过, 2=拒绝]")
    is_enable: int = Field(description="是否显示: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")
    user: dict = Field(description="用户信息")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "category": "",
                "sort": 0,
                "audit_result": "",
                "audit_status": 0,
                "is_enable": 0,
                "create_time": "2023-11-08 10:19:19",
                "update_time": "2024-06-30 17:35:24",
                "user": {}
            }
        }
